import type { TableColumn } from '@/framework/components/core/super-table';

/**
 * columns
 */
export type TableListItem = {
  id;
  batchNo;
  createTime;
  status;
  creatorName;
  selectType;
  result;
  inventoryTime;
};
export type TableColumnItem = TableColumn<TableListItem>;

const getSvg = (state) => {
  if (state) {
    return (
      // @ts-ignore
      <svg t='1680592527152' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='2909' width='45' height='20'>
        <path
          d='M512.024381 0C229.205333 0 0 229.205333 0 512.024381 0 794.770286 229.205333 1024 512.024381 1024 794.770286 1024 1024 794.770286 1024 512.024381 1024 229.205333 794.770286 0 512.024381 0M849.603048 353.328762l-385.462857 385.462857c-9.411048 9.411048-21.723429 14.09219-34.06019 14.09219s-24.697905-4.681143-34.084571-14.09219l-221.622857-221.647238c-18.822095-18.822095-18.822095-49.322667 0-68.120381 18.822095-18.846476 49.322667-18.846476 68.144762 0l187.562667 187.562667 351.378286-351.402667c18.822095-18.822095 49.322667-18.822095 68.144762 0C868.425143 304.006095 868.425143 334.506667 849.603048 353.328762'
          fill='#5bdc9c'
          p-id='2910'
          data-spm-anchor-id='a313x.7781069.0.i0'
          class=''
        />
      </svg>
    );
  } else {
    return (
      // @ts-ignore
      <svg t='1680592590083' class='icon' viewBox='0 0 1024 1024' version='1.1' xmlns='http://www.w3.org/2000/svg' p-id='3923' width='45' height='20'>
        <path
          d='M512 981.333333C252.8 981.333333 42.666667 771.2 42.666667 512S252.8 42.666667 512 42.666667s469.333333 210.133333 469.333333 469.333333-210.133333 469.333333-469.333333 469.333333z m44.245333-469.333333l159.914667-159.914667a31.274667 31.274667 0 1 0-44.245333-44.245333L512 467.754667 352.085333 307.84a31.274667 31.274667 0 1 0-44.245333 44.245333L467.754667 512l-159.914667 159.914667a31.274667 31.274667 0 1 0 44.245333 44.245333L512 556.245333l159.914667 159.914667a31.274667 31.274667 0 1 0 44.245333-44.245333L556.245333 512z'
          fill='#F5222D'
          p-id='3924'
        />
      </svg>
    );
  }
};

export const baseColumns: TableColumnItem[] = [
  {
    type: 'seq',
    title: '序号',
    width: 60,
  },
  {
    title: '盘点单号',
    field: 'batchNo',
    hideInSearch: true,
  },
  {
    title: '创建时间',
    field: 'createTime',
    formItemProps: {
      component: 'RangePicker',
      componentProps: {
        valueFormat: 'YYYY-MM-DD',
      },
    },
  },
  {
    title: '状态',
    field: 'status',
    dict: 'InventoryState',
    hideInTable: true,
  },
  {
    title: '盘点人',
    field: 'creatorName',
    hideInSearch: true,
  },
  {
    title: '抽检方式',
    field: 'selectType',
    formatter: ({ cellValue }) => (cellValue === 1 ? '系统推荐' : '手动选择'),
    hideInSearch: true,
  },
  {
    title: '盘点结果',
    field: 'result',
    hideInSearch: true,
  },
  {
    title: '盘点日期',
    field: 'inventoryTime',
    hideInSearch: true,
  },
  {
    title: '样本盘点',
    slots: {
      default: ({ row }) => {
        return getSvg(row.status >= 3);
      },
    },
    hideInSearch: true,
  },
  {
    title: '底单存档',
    field: 'status',
    slots: {
      default: ({ row }) => {
        return getSvg(row.status === 10);
      },
    },
    hideInSearch: true,
  },
];
